package com.fourth.shopping.controller;


import com.fourth.shopping.commons.OrdersTableSearch;
import com.fourth.shopping.commons.TableData;
import com.fourth.shopping.entity.Address;
import com.fourth.shopping.service.OrderService;

import com.fourth.shopping.vo.OrdersVO;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("orders")
public class OrderController {
    @Resource
    private OrderService orderService;

    @RequestMapping("/getOrderAsPage.do")
    public TableData<OrdersVO> getOrderAsPage(@RequestParam("offset") Integer offset,
                                              @RequestParam("limit") Integer limit,
                                              OrdersTableSearch ordersTableSearch){
        return orderService.getOrderAsPage(ordersTableSearch,offset,limit);
    }

    @RequestMapping("/modifyOrdersAddress.do")
    public Boolean modifyOrdersAddress(@RequestParam("ono")String ono,
                                       Address address){
        if(ono == null || "".equals(ono)){
            return false;
        }
        return orderService.modifyOrdersAddress(ono,address);
    }
}
